<?php $this->header(); ?>
<div class="wrap">
    <div class="nav">
        <div class="return"><a href="/?g=Admin&m=<?php echo MODULE; ?>&a=group">返回上一级</a></div>
        <ul class="cc">
            <li class="current" ><a href="/?g=Admin&m=<?php echo MODULE; ?>&a=competence&id=<?php echo $_GET['id']; ?>">更新用户组权限</a></li>
        </ul>
    </div>
    <div class="J_tabs_contents">
        <form action="/?g=Admin&m=User&a=updateCompetence&id=<?php echo $_GET['id']; ?>" method="post">
            <div>
                <?php foreach( $list as $key => $value) : ?>
                    <?php foreach ($value as $_key => $_value) : ?>
                <div class="h_a"><?php echo $_value['title']; ?><input type="hidden" name="competence[]" value="<?php echo $_value['id']; ?>" /></div>
                        <div class="table_full">
                            <table width="100%">
                                <col class="th" />
                                <col width="400" />
                                <?php foreach ($_value['imit'] as $__key => $__value) : ?>
                                    <tr>
                                    <input type="hidden" name="competence[]" value="<?php echo $__value['id']; ?>" />
                                    <th><a href="javascript:void(0);"><?php echo $__value['title']; ?></a><br />
                                        <label><input type="checkbox" /><span>全选</span></label>
                                    </th>
                                    <td>
                                        <ul class="three_list cc">
                                            <?php foreach ($__value['imit'] as $___key => $___value) : ?>
                                                <li><label><input type="checkbox" name="competence[]" value="<?php echo $___value['id']; ?>" /><span><?php echo $___value['title']; ?></span></label></li>
                                            <?php endforeach; ?>
                                        </ul>
                                    </td>

                                    </tr>
                                <?php endforeach; ?>

                            </table>
                        </div>
                    <?php endforeach; ?>
                <?php endforeach; ?>

            </div>
            <div class="btn_wrap">
                <div class="btn_wrap_pd">
                    <input type="submit" value="更新" class="btn btn_submit" />
                    <a href="/?g=Admin&m=<?php echo MODULE; ?>&a=group" class="btn btn_submit">取消</a>

                </div>
            </div>
        </form>
    </div>


</div>
<script>
    $(document).ready(function() {
        //全选功能
        $("table th input").each(function(data) {
            $(this).click(function() {
                if ($(this).attr("checked") == "checked") {
                    $("table td:eq(" + data + ") input").attr("checked", "true");
                } else {
                    $("table td:eq(" + data + ") input").removeAttr("checked");
                }
            });
        });
        //判断已选择的
        var competence = [<?php echo $competence; ?>];
        $("table td input").each(function(data) {
            if ($.inArray(parseInt(this.value, 10), competence) > -1) {
                $(this).attr("checked", "true");
            }
        });
    });
</script>
<?php $this->footer(); ?>
